﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Web.Utils
{
    public class CodeHelper
    {
        private static readonly char DEPARTMENT_DELIM = '-';

        public static string GetDepartmentCode(string code)
        {
            int pos = code.IndexOf(DEPARTMENT_DELIM);
            if (pos >= 0)
            {
                string[] codes = code.Split(DEPARTMENT_DELIM);
                return codes[codes.Length - 1];
            }
            else
            {
                return code;
            }
        }

        public static string GenDepartmentCode(string parentCode, string code)
        {
            return parentCode + DEPARTMENT_DELIM + code;
        }
    }
}